package Demo3;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (true){
            String oper = scanner.next();
            if (oper.equals("new")){

                boolean flag = true;
                Student stu;
                try{
                    String name = scanner.next();
                    int score = scanner.nextInt();
                    //scanner.nextLine();
                    stu = new Student(name, score);
                    stu.SetName();
                    stu.addScore(score);
                    System.out.println(stu);
                }catch(IllegalNameException  | IllegalScoreException e){
                    System.out.println(e);
                }catch(Exception e){
                    System.out.println("java.util.NoSuchElementException");
                }
            }else{
                break;
            }


        }

        scanner.close();
        System.out.println("scanner closed");
    }




}


